﻿using System;

namespace OpcDaNet.Dx
{
    [Serializable]
    public class ItemIdentifier : OpcDaNet.ItemIdentifier
    {
        public string Version
        {
            get
            {
                return this.m_version;
            }
            set
            {
                this.m_version = value;
            }
        }

        public ItemIdentifier()
        {
        }

        public ItemIdentifier(string itemName) : base(itemName)
        {
        }

        public ItemIdentifier(string itemPath, string itemName) : base(itemPath, itemName)
        {
        }

        public ItemIdentifier(OpcDaNet.ItemIdentifier item) : base(item)
        {
        }

        public ItemIdentifier(ItemIdentifier item) : base(item)
        {
            if (item != null)
            {
                this.m_version = item.m_version;
            }
        }

        public override bool Equals(object target)
        {
            if (typeof(ItemIdentifier).IsInstanceOfType(target))
            {
                ItemIdentifier itemIdentifier = (ItemIdentifier)target;
                return itemIdentifier.ItemName == base.ItemName && itemIdentifier.ItemPath == base.ItemPath && itemIdentifier.Version == this.Version;
            }
            return false;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        private string m_version;
    }
}
